<template>
  <div>
    <nav-bottom-bar v-if="item.templateType == 1" :pageName="pageName" :itemIndex="0" :isHomePage="isHomePage" :customNav="item"></nav-bottom-bar>
    <div v-else-if="item.templateType == 2 && item.btnInfo" :class="item.isWhitespace == 1 ? '':'c-ph24 c-pv24'" class="c-pf c-w100 c-p-l0 c-p-r0 c-p-b0 c-m-0auto c-bg-white c-pz100" id="customButton">
      <div
        @click="clickButton(item.btnInfo.navType, item.btnInfo)"
        class="c-fs28 c-textAlign-c"
        :style="{'color': item.btnInfo.color,'background': item.btnInfo.bgColor,'border': '1px solid' + item.btnInfo.borderColor,'height': item.btnInfo.height + 'px','line-height': item.btnInfo.height + 'px','border-radius': (item.btnInfo.radius ? item.btnInfo.height / 2 + 'px' : '')}"
      >
        {{item.btnInfo.name}}
      </div>
    </div>
  </div>
</template>
<script>
import NavBottomBar from "@/components/templates/common/navBottomBar.vue";
import { utilJs } from "@/utils/common.js";
import { appRouterChange } from "@/mixin/appRouterPush.js";
export default {
  mixins: [appRouterChange],
  components: {
    NavBottomBar
  },
  props: {
    item: {
      type: Object,
      default: () => {
        return {}
      },
    },
    pageName: {//首页 INDEX 预览页 PREVIEW_INDEX 微页面 MICRO_PAGE
      type: String,
      default: "INDEX"
    },
    isHomePage: {
      type: Boolean,
      default: true
    },
  },
  data() {
    return {
      navMap: global.navMap,
    };
  },
  methods: {
    clickButton(navType, item) {
      if (this.pageName == 'PREVIEW_INDEX') {
        return;
      }
      if (navType == 0) {
        this.$routerGo(this, "push", { path: "/" });
      } else if (navType == 1) {
        this.$routerGo(this, "push", { path: "/mall/mallIndex" });
      } else if (navType == 2) {
        this.$routerGo(this, "push", { path: "/activity/activityIndex" });
      } else if (navType == 3) {
        this.$routerGo(this, "push", { path: "/message/messageIndex" });
      } else if (navType == 4) {
        this.$routerGo(this, "push", { path: "/member/memberIndex" });
      } else if (navType == 5) {
        this.$routerGo(this, "push", { path: "/homePage/live/liveList" });
      } else if (navType == 6) {
        this.$routerGo(this, "push", { path: "/homePage/clockIn/clockInList" });
      } else if (navType == 7) {
        this.$routerGo(this, "push", { path: "/homePage/column/columnList" });
      } else if (navType == 8) {
        this.$routerGo(this, "push", { path: "/homePage/examination/examinationList" });
      } else if (navType == 9) {
        this.$routerGo(this, "push", { path: "/homePage/socialGroup/socialGroupList" });
      } else if (navType == 10) {
        this.$routerGo(this, "push", { path: "/homePage/collage/collageList" });
      } else if (navType == 12) {
        this.$routerGo(this, "push", { path: "/homePage/qa/answerLord" });
      } else if (navType == 13) {
        this.$routerGo(this, "push", { path: "/homePage/reservation/reservationList" });
      } else if (navType == 14) {
        this.$routerGo(this, "push", { path: "/homePage/word/wordList" });
      } else if (navType == 15) {
        this.$routerGo(this, "push", { path: "/homePage/booking/bookingList" });
      } else if (navType == 16) {
        this.$routerGo(this, "push", { path: "/homePage/mutuaTest/mutuaTestList" });
      } else if (navType == 17) {
        this.$routerGo(this, "push", { path: "/homePage/voiceTest/voiceTestList" });
      } else if (navType == 18) {
        this.$routerGo(this, "push", { path: "/homePage/package/packageList" });
      } else if (navType == 19) {
        this.$routerGo(this, "push", { path: "/homePage/camp/campList" });
      } else if (navType == 20) {
        this.$routerGo(this, "push", { path: "/homePage/datum/datumList" });
      } else if (navType == 21) {
        this.$routerGo(this, "push", { path: "/homePage/privateClass/classList" });
      } else if (navType == 22) {
        if (localStorage.getItem("microPageScroll")) {
          localStorage.removeItem("microPageScroll"); //微页面返回上一级回到上次滑动的位置，每次刷新页面，从头加载
        }
        if (item.mId) {
          this.$routerGo(this, "push", { path: "/homePage/microPage/microPage", query: {'mId': item.mId} });
        } else {
          let url = item.otherHref;
          if (url) {
            if (!url.includes("http") && !url.includes("https")) {
              url = "http://" + url;
            }
            utilJs.locationHref(url, this);
          }
        }
      } else if (navType == 23) {
        this.$routerGo(this, "push", { path: "/edu/eduList" });
      } else if (navType == 24) {
        let $this = this;
        let toPath = '/edu/faceTeaching';
        if (!localStorage.getItem("jwRole")) {
          utilJs.getMethod(global.apiurl + 'members/jwRole', function (res) { // 获取当前用户身份，是教务系统的讲师还是学员
            localStorage.setItem("jwRole", res.role);
            if (res.role == 2) {
              toPath = '/edu/courseManagment';
            }
            $this.$routerGo($this, "push", { path: toPath });
          });
        } else {
          toPath = localStorage.getItem("jwRole") == 2 ? '/edu/courseManagment' : '/edu/faceTeaching';
          this.$routerGo(this, "push", { path: toPath });
        }
      } else if (navType == -2) {
        let url = item.otherHref;
        if (url) {
          if (!url.includes("http") && !url.includes("https")) {
            url = "http://" + url;
          }
          utilJs.locationHref(url, this);
        }
      }
    },
  },
};
</script>

<style scoped>
.search-bg {
  border-radius: 0.2rem;
  background: #f4f7f9;
}
.fixedTop {
  position: fixed;
  left: 0;
  right: 0;
  top: 0;
  margin: 0 auto;
  max-width: 16rem;
}
</style>
